<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    //三个变量表示三个位置的数据 上 当 下
    function fn(head) {
        let prev = null
        let curr = head
        while (curr != null) {
            let next = curr.next
            curr.next = prev
            prev = curr
            curr = next
        }
        return prev
    }

    class Head {
        constructor(val, next) {
            this.value = val
            this.next = next
        }
    }
    const h = new Head(1, new Head(2, new Head(3, new Head(4, null))))

    console.log(fn(h), "---");


</script>

</html>